<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Landowners extends Model  {

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'landowners';
	protected $primaryKey  ='landowners_id';

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * Indicates if the primary key should be incrementing.
     *
     * @var bool
     */
    //protected $incrementing =false;

    /**
     * The storage format of the model's date columns.
     *
     * @var string
     */
    //protected $dateFormat = 'U';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    //protected $fillable = ['name'];

    /**
     * The attributes that aren't mass assignable.
     *
     * @var array
     */
    //protected $guarded = ['price'];


    //use SoftDeletes;

    /**
     * The attributes that should be mutated to dates.
     *
     * @var array
     */
    //protected $dates = ['deleted_at'];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = array('cate_id_1', 'cate_id_2', 'cate_id_3', 'cate_id_4',
        'weight','unit','parameter','remark',
        'childrens','pivot','parents','albums','specs');

    /**
     * The goods that belong to the goods.
     */
    public function childrens()
    {
        return $this->belongsToMany('App\Models\Landowners','goods_subitems','landowners_id');
    }

    /**
     * The goods that the goods is belong to .
     */
    public function parents()
    {
        return $this->belongsToMany('App\Models\Goods','goods_subitems','sub_goods_id','goods_id');
    }

    public function store()
    {
        return $this->belongsTo('App\Models\Store','store_id','store_id');
    }

    public function albums(){
        return $this->hasMany('App\Models\LandownersImage','landowners_id','landowners_id');
    }

    public function statics(){
        return $this->hasOne('App\Models\GoodsStatistics','goods_id','goods_id');
    }

    public function specs(){
        return $this->hasMany('App\Models\LandownersSpec','landowners_id','landowners_id');
    }

//    public function attrs(){
//        return $this->hasMany('App\Models\GoodsAttr','goods_id','goods_id');
//    }
//
//    public function qas(){
//        return $this->hasMany('App\Models\GoodsQa','goods_id','goods_id');
//    }

    public function orderGoods(){
        return $this->hasMany('App\Models\OrderGoods','goods_id','goods_id');
    }

}
